/*
 * @Author: dailuyu
 * @Date: 2021-08-17 21:02:39
 * @Email: dly@hyrctec.com
 * @LastEditors: dailuyu
 * @LastEditTime: 2021-08-17 23:17:44
 * @Company: hyrc
 * @FilePath: \TaskErrorManageApi\database\Dao\users\users_dao.js
 * @Description:
 */
let { pool } = require("../../DBConfig.js")
let { AddUser, DeleteUser, QueryUser, Login } = require('./users_sql.js')
module.exports = {
  login: function (loginName, passWord, callback) { // users表中增加user操作
    let sqlparam = [
      user.LoginName ? user.LoginName : "",
      user.Password ? user.Password : "",
    ]
    pool.query(Login, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  add: function (user, callback) { // users表中增加user操作
    let sqlparam = [
      user.Id ? user.Id : "",
      user.UserName ? user.UserName : "",
      user.LoginName ? user.LoginName : "",
      user.RoleId ? user.RoleId : "",
      user.Password ? user.Password : "",
      user.Remark ? user.Remark : "",
    ]
    pool.query(AddUser, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  deleted: function (params, callback) { // users表中删除指定user操作
    let { id } = params
    let sqlparam = [id]
    pool.query(DeleteUser, sqlparam, function (error, result) {
      if (error) throw error
      callback(result)
    })
  },
  query: function (params, callback) { // users表中查询指定user操作
    let { id } = params
    let sqlparam = [id]
    pool.query(QueryUser, sqlparam, function (error, result) {
      if (error) throw error
      callback(result[0])
    })
  },
}